/*
 * ECARX Technology Limited is the owner of the copyright and the trade secret of this software.
 * Without permission, no one has the right to obtain, disclose or use this software in any way.
 */

package com.ecarx.systemui.plugin.utils;

import static com.ecarx.systemui.plugin.utils.WifiUtils.WifiCapability.WIFI_NONE;

public class WifiUtils {

    public static final String CAPABILITY_WEP = "WEP";
    public static final String CAPABILITY_PSK = "PSK";
    public static final String CAPABILITY_EAP = "EAP";
    public static final String CAPABILITY_SAE = "SAE";
    public static final String CAPABILITY_EAP_B = "SUITE-B";
    public static final String CAPABILITY_WAPI = "WAPI";
    public static final String CAPABILITY_OWE = "OWE";

    public static boolean isWifiSecurity(String capabilities) {
        if (capabilities.contains(CAPABILITY_SAE)) {
            return true;
        }
        if (capabilities.contains(CAPABILITY_EAP_B)) {
            return true;
        }
        if (capabilities.contains(CAPABILITY_EAP)) {
            return true;
        }
        if (capabilities.contains(CAPABILITY_PSK)) {
            return true;
        }
        if (capabilities.contains(CAPABILITY_WEP)) {
            return true;
        }
        if (capabilities.contains(CAPABILITY_WAPI) || capabilities.contains(CAPABILITY_OWE)) {
            return true;
        }
        return false;
    }

    public static WifiCapability getWifiSecurityType(String capabilities) {
        if (capabilities.contains(CAPABILITY_PSK)) {
            return WifiCapability.WIFI_WPA;
        }
        if (capabilities.contains(CAPABILITY_WEP)) {
            return WifiCapability.WIFI_WEP;
        }
        return WifiCapability.WIFI_NONE;
    }

    public enum WifiCapability {
        WIFI_WEP, WIFI_WPA, WIFI_NONE
    }
}
